﻿#include "FITKAcousticsPhysics.h"
#include "FITK_Kernel/FITKAppFramework/FITKAppFramework.h"
#include "FITK_Kernel/FITKAppFramework/FITKGlobalData.h"
#include "FITK_Kernel/FITKAppFramework/FITKAppSettings.h"
#include "FITKAcousticsPhysicalIniter.h"
#include "FITKGlobalFrequencyDomain.h"
#include "FITKAcousticsAbsMaterial.h"
#include "FITKAcousticsAbsPhysicsProp.h"
#include "FITKAcousticsAbsNCT.h"
#include "FITKAcousticsSpectraManager.h"
#include "FITKAcousticsLoadManager.h"
#include <QColor>

namespace Acoustics
{

    FITKAcousticsPhysics::FITKAcousticsPhysics()
    {
        //创建对象
        _frequencyDomain = new FITKGlobalFrequencyDomain;
        _materialManager = new FITKAcousticsMaterialManager;
        _physicsPropManager = new FITKAcousticsPhysicsPropManager;
        _acousticsNCTManager = new FITKAcousticsNCTManager;
        _spectraManager = new FITKAcousticsSpectraManager;
        _loadManager = new FITKAcousticsLoadManager;
        //初始化
        FITKAcousticsPhysicalIniter initer(this);
        initer.init();
    }

    FITKAcousticsPhysics::~FITKAcousticsPhysics()
    {
        //释放内存
        if (_frequencyDomain) delete _frequencyDomain;
        if (_materialManager) delete _materialManager;
        if (_physicsPropManager) delete _physicsPropManager;
        if (_acousticsNCTManager) delete _acousticsNCTManager;
        if (_spectraManager) delete _spectraManager;
        if (_loadManager) delete _loadManager;
    }

    FITKAcousticsPhysics* FITKAcousticsPhysics::GetAcousticsPhysicsFromFrame()
    {

        if (FITKAPP == nullptr) return nullptr;
        //从全局数据获取
        return FITKAPP->getGlobalData()->getPhysicsData<FITKAcousticsPhysics>();
    }

    FITKGlobalFrequencyDomain* FITKAcousticsPhysics::getFrequencyDomain()
    {
        return _frequencyDomain;
    }

    Acoustics::FITKAcousticsMaterialManager* FITKAcousticsPhysics::getMaterialManager()
    {
        return _materialManager;
    }

    Acoustics::FITKAcousticsPhysicsPropManager* FITKAcousticsPhysics::getPhysicsPropManager()
    {
        return _physicsPropManager;
    }

    Acoustics::FITKAcousticsNCTManager* FITKAcousticsPhysics::getFITKAcousticsNCTManager()
    {
        return _acousticsNCTManager;
    }

    Acoustics::FITKAcousticsSpectraManager* FITKAcousticsPhysics::getFITKAcousticsSpectraManager()
    {
        return _spectraManager;
    }

    FITKAcousticsLoadManager* FITKAcousticsPhysics::getFITKAcousticsLoadManager()
    {
        return _loadManager;
    }
    
    void FITKAcousticsPhysics::clearAcousticsPhysics()
    {
        if (_materialManager)_materialManager->clear();
        if (_physicsPropManager)_physicsPropManager->clear();
        if (_acousticsNCTManager)_acousticsNCTManager->clear();
        if (_spectraManager)_spectraManager->clear();
        if (_loadManager)_loadManager->clear();
    }
    
}
 

